﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sinacor.OMM.HealthMonitor.Entity.Common;

namespace Sinacor.OMM.HealthMonitor.Entity.Receiver
{
    [Serializable()]
    public class Statistic : IHealthDataReset
    {
        HealthEntityBase _healthEntityBase;

        public Statistic()
        {
            _healthEntityBase = new HealthEntityBase();
        }
        
        public Statistic(HealthEntityBase healthEntityBase)
        {
            _healthEntityBase = healthEntityBase;
        }

        // Mensagens Recebidas por Segundo
        long _receivedMessagesForSecond = -1;
        public long ReceivedMessagesForSecond
        {
            get { return _receivedMessagesForSecond; }
            set 
            { 
                _receivedMessagesForSecond = value;
                _healthEntityBase.LastUpdate = DateTime.Now;
            }
        }

        //Total de Mensagens Recebida
        long _receivedMessagesQuantity = -1;
        public long lReceivedMessagesQuantity
        {
            get { return _receivedMessagesQuantity; }
            set 
            { 
                _receivedMessagesQuantity = value;
                _healthEntityBase.LastUpdate = DateTime.Now;
            }
        }

        //Data e hora da última mensagem recebida
        DateTime _lastReceivedMessageTimeStamp = DateTime.MinValue;
        public DateTime LastReceivedMessageTimeStamp
        {
            get { return _lastReceivedMessageTimeStamp; }
            set 
            { 
                _lastReceivedMessageTimeStamp = value;
                _healthEntityBase.LastUpdate = DateTime.Now;
            }
        }

        // ID da última mensagem recebida
        string _lastReceivedMessageId = String.Empty;
        public string LastReceivedMessageId
        {
            get { return _lastReceivedMessageId; }
            set 
            { 
                _lastReceivedMessageId = value;
                _healthEntityBase.LastUpdate = DateTime.Now;
            }
        }

        // Mensagens represadas na fila interna
        long _internalQueuedMessages_01_Quantity = -1;
        public long InternalQueuedMessages_01_Quantity
        {
            get { return _internalQueuedMessages_01_Quantity; }
            set 
            { 
                _internalQueuedMessages_01_Quantity = value;
                _healthEntityBase.LastUpdate = DateTime.Now;
            }
        }

        // Limite de mensagens na fila
        long _InternalQueuedMessages_01_HealthLimit = -1;
        public long TotalInternalQueuedMessages
        {
            get { return _InternalQueuedMessages_01_HealthLimit; }
            set 
            { 
                _InternalQueuedMessages_01_HealthLimit = value;
                _healthEntityBase.LastUpdate = DateTime.Now;
            }
        }

        public void Reset()
        {
            ReceivedMessagesForSecond = 0;
            lReceivedMessagesQuantity = 0;
            TotalInternalQueuedMessages = 0;
            LastReceivedMessageTimeStamp = DateTime.Now;
            LastReceivedMessageId = string.Empty;
        }
    }
}
